package co.sanduche.util;


public abstract class DepVal1<D0, T> extends DepVal<T> {

	private DepVal<D0> dep0;
	private D0 d0;

	public DepVal1(DepVal<D0> d0) {
		dep0 = d0;
	}

	private void setDep0(D0 d0) {
		this.d0 = d0;

		startAsyncGetter();
	}

	private void startAsyncGetter() {
		if (d0 != null) {

			asyncGetter(d0);
		}
	}

	public abstract void asyncGetter(D0 d0);

	@Override
	protected void solveValue() {
		dep0.onReady(new EPCallback<D0>() {
			@Override
			public void onSuccess(D0 val) {
				setDep0(val);
			}

			@Override
			public void onFailure(Throwable e) {
				failed(e);
			}

		});
	}
}
